package bitoperations;
//不用加号的加法
public class Sum {
    public static void main(String[] args) {
        int sum = sum(1, 4);
        System.out.println(sum);
    }

    public static int sum(int a, int b){
        int sum = a;
        while(b != 0){
            sum = a ^ b;
            b = (a & b)<< 1;
            a = sum;
        }
        return sum;
    }
}
